<script setup lang="ts">
import { emptyHandle } from '@vc/utils';
import baseInfo from './base-info.vue';
interface Props {
  companyInfo?: Record<string, any>;
}

const {
  companyInfo
} = defineProps<Props>();

const infos = computed(() => {
  return companyInfo?.basicInfo;
});

const baseInfoShow = ref(false);
</script>

<template>
  <div class="header-info">
    <div class="company-info">
      <span class="title">{{ companyInfo?.name }}</span>
      <span class="phone">
       <img v-if="companyInfo?.phone" src="../assets/phone.png" width="16" height="16" alt="" />
       <span>{{ companyInfo?.phone }}</span>
      </span>
    </div>
    <div class="content">
      <div class="label-con" v-if="companyInfo?.labels?.length">
        <span v-for="(item, index) in companyInfo.labels"
          :style="{backgroundColor: item.bgColor, color: item.color, borderColor: item.bgColor}"
          :key="index" class="label">
          {{ item.name }}
        </span>
      </div>

      <div class="infos" v-if="infos">
        <span class="item">法定代表人：{{ emptyHandle(infos?.legalPerson) }}</span>
        <span class="item">注册资本：{{ emptyHandle(infos?.registeredCapital) }}</span>
        <span class="item">成立日期：{{ emptyHandle(infos?.foundationDate) }}</span>
        <span class="item">地区：{{ emptyHandle(infos?.registeredRegion) }}</span>
        <span class="item">行业：{{ emptyHandle(infos?.industryCategory) }}</span>
        <span class="item more" @click="baseInfoShow = true">更多</span>
        <!--<vc-clamp-toggle class="item inline" :text="'行业: ' + emptyHandle(infos?.scopeOfOperation)"-->
        <!--  :toggleText="['更多', '收缩']" />-->
      </div>
    </div>
  </div>
  <base-info v-model:show="baseInfoShow" :id="companyInfo?.id" :companyName="companyInfo?.name" />
</template>

<style lang="scss" scoped>
.header-info {
  width: 1200px;
  margin: 0 auto;
  padding-bottom: 20px;

  .company-info {
    .title {
      font-weight: 500;
      font-size: 20px;
      color: #111111;
    }

    .phone {
      font-size: 14px;
      font-weight: 400;
      color: #333333;
      display: inline-flex;
      justify-content: flex-start;
      align-items: center;
      margin-left: 12px;
    }
  }

  .content {
    margin-top: 16px;
    // padding: 12px 15px;
    background: #FFFFFF;

    .label {
      padding: 2px 5px;
      border-radius: 2px;
      border: 1px solid;
      font-weight: 400;
      font-size: 12px;
      line-height: 14px;
      display: inline-block;
      margin-bottom: 7px;
      margin-right: 5px;
    }

    .infos {
      margin-top: 7px;
      .item {
        font-weight: 400;
        font-size: 14px;
        color: #333333;
      }

      .item:not(:last-child) {
        &::after {
          content: '|';
          display: inline-block;
          margin: 0 15px;
          height: 10px;
          width: 1px;
          transform: translateY(-1px);
          color: rgba(0,0,0,0.1);
        }
      }
      .item.more {
        cursor: pointer;
        color: #008EF4;
        // color: var(--vc-color-primary);
      }
    }
  }
}
</style>
